import java.util.*;
import java.text.*;

public class DateExample{

    //this programe is built for test date-related functions.

    public static void main(String[] args) throws Exception{

        Date d1 = new Date();
        DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss SSS");
        String str = df.format(d1);//从文本到日期

        //从日期到文本
        Date d2 = df.parse("2018-09-09 09:56:22 012");

        System.out.println(str);
        System.out.println(d2);
    }
    
}